<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/common.js"></script>
 <script src="js/rem.js"></script>
 <script src="js/layer.js"></script>
 <script type="text/javascript">
  isLogin();
 </script>
 <link rel="stylesheet" href="css/common.css">
 <link rel="stylesheet" type="text/css" href="css/css.css">
</head>
<body>
<!--头部-->
<div class="jui_top_bar">
    <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
    <div class="jui_top_middle" data-ch="语言设定" data-en="Language Setting">语言设定</div>
</div>
<!--头部end--> 
<!--主体-->
<form action="">
<div class="jui_main">
     <!--  -->
     <div class="jui_pad_12">
          <div class="bg_light_black jui_bor_rad_15 jui_pad_20">
                <p class="col_fff jui_pad_b5 f30" data-ch="语言选择" data-en="Select language">选择语言</p>
                <div class="jui_h12"></div>
                <div class="jui_flex_row_center jui_bg_fff jui_bor_rad_5 jui_pad_r8">
                     <select id="language" class="jui_flex1 yysd_input">
                           <option value="中文">中文</option>
                           <option value="English">English</option>
                           
                     </select>
                     <img class="jui_arrow_rimg" src="icons/down.png">
                </div>
          </div>
     </div>
     <!-- 实名认证提交end -->
</div>
</form>
<!--主体end-->
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/common.js"></script>
<script>
 var language_type = localStorage.getItem("language_type"); // 1-中文 2-英文 默认中文
 $(document).ready(function(){ // 将之前被选中的语言放在第一个默认位置
  if(language_type == 1){
   $("#language").find("option").first().attr("value", "中文")
   $("#language").find("option").first().html("中文")
   $("#language").find("option").last().attr("value", "English")
   $("#language").find("option").last().html("English")
  } else if(language_type == 2){
   $("#language").find("option").first().attr("value", "English")
   $("#language").find("option").first().html("English")
   $("#language").find("option").last().attr("value", "中文")
   $("#language").find("option").last().html("中文")
  }
  language();
  documentName()
 });

 //语言切换时, 确定被选择的语言language_type类型, 切换当前页面语言, 并存放localStorage
 $("#language").change(function(){ 
  let checked = $(this).children('option:selected').val()
  
  if(checked == '中文'){
   language_type = 1;
   var chObj = $('[data-ch]');
   chObj.each(function () {
   $(this).html($(this).attr("data-ch"))
   })
  }else if(checked == "English"){
   language_type = 2;
   var enObj = $('[data-en]');
   enObj.each(function () {
   $(this).html($(this).attr("data-en"))
   })
  }
  localStorage.setItem("language_type",language_type);
 })
    
</script>
</html>